import tornado

from tornado.web import RequestHandler, Application, url


class RequestPostDemo(RequestHandler):
    def get(self):
        self.write('<html><body><form action="/" method="POST">'
                   '<input type="text" name="message">'
                   '<input type="submit" value="Submit">'
                   '</form></body></html>')

    def post(self):
        self.set_header("Content-Type", "text/plain")
        self.write("You wrote " + self.get_body_argument("message"))


app = Application([
    url(r"/", RequestPostDemo),
])


def _test_post():
    """
    _test_post()
    >
    192.168.1.103:8000
    """
    app.listen(8000)
    tornado.ioloop.IOLoop.current().start()


if __name__ == '__main__':
    _test_post()
